a = input()
f = True
ot = ['(', '[', '{', '<']
za = [')', ']', '}', '>']
ob = ['(', ')']
kv = ['[', ']']
fi = ['{', '}']
st = ['<', '>']
for i in range(len(a)):
    if (a[0] in za) or (a[i] == '(' and a[i + 1] in za and a[i + 1] not in ob) or (a[i] == '[' and a[i + 1] in za and a[i + 1] not in kv) or (a[i] == '{' and a[i + 1] in za and a[i + 1] not in fi) or (a[i] == '<' and a[i + 1] in za and a[i + 1] not in st):
        f = False
if a.count('(') != a.count(')') and a.count('[') != a.count(']') and a.count('{') != a.count('}') and a.count('<') != a.count('>'):
    f = False
print(f)